<template>
	<view class="container plr15">
		<view class="flex align-center boxshadow20 bgWhite  menudata ptb15 ">
		 <image src="/static/images/user.png" mode="widthFix" style="width: 50rpx;" class="mr5"></image>	学员姓名: <view class="flex1 justify-end"> {{form.nickname}}</view>
		</view>
		<view class="mt15  bgWhite radius10 boxshadow20 pb15" v-if="type=='0'">
			<view class="moduletitle  align-center justify-start plr15">
				<text></text>
				<view class="ft16 ml10">
					上传头像
				</view>
			</view>
			<view class="maininfo justify-center align-center">
				<image v-if="form.avatar" :src="form.avatar" class="mt15" mode="widthFix"></image>
				<view v-else class="mt20 plus justify-center align-center" @click="upImg">
					<uv-icon color="#4080FF" size="25" name="plus"></uv-icon>
				</view>
			</view>
		</view>
		<view class="mt15  bgWhite radius10 boxshadow20 pb15" v-if="type=='1'">
			<view class="moduletitle  align-center justify-start plr15">
				<text></text>
				<view class="ft16 ml10">
					上传证书照
				</view>
			</view>
			<view class="maininfo justify-center align-center">
				<image v-if="form.zhengshu" :src="form.zhengshu" class="mt15" mode="widthFix"></image>
				<view v-else class="mt20 plus justify-center align-center" @click="upImg">
					<uv-icon color="#4080FF" size="25" name="plus"></uv-icon>
				</view>
				
			</view>
			<view class="mt20 mb20 mlr15 ptb15 plr15 radius10 ft12" style="background-color: #f1f1f1;color: #ccc;">
				请上传/现拍一张照片，免冠，关闭美颜功能，10M以内
			</view>
		</view>
		<block v-if="type=='2'">
			<view class="mt15  bgWhite radius10 boxshadow20 pb15" >
				<view class="moduletitle  align-center justify-start plr15">
					<text></text>
					<view class="ft16 ml10">
						上传身份证正面(人像面)
					</view>
				</view>
				<view class="maininfo justify-center align-center">
					<image v-if="form.front_image" :src="form.front_image" class="mt15" mode="widthFix"></image>
					
					<image style="width: 400rpx;" src="/static/images/sfz.png" mode="widthFix"  @click="upImg(1)"></image>
				<!-- 	<view v-else class="mt20 plus justify-center align-center">
						<uv-icon color="#4080FF" size="25" name="plus"></uv-icon>
					</view>
					 -->
				</view>
				<view class="ft12 mlr15 mt15" style="color: red;">
					    温馨提示：请您在上传身份证时，确保身份证的正反面照片均为正面朝上、水平放置。照片应清晰可见，不得竖立或倾斜。
				</view>
				<view class="mt10 mb10 mlr15 ptb15 plr15 radius10 ft12" style="background-color: #f1f1f1;color: #ccc;">
					检查照片预览，再次确认照片方向正确，无倾斜
				</view>
				<view class="mt10 mb20 mlr15 ptb15 plr15 radius10 ft12" style="background-color: #f1f1f1;color: #ccc;">
					以免影响审核进度
				</view>
			</view>
			<view class="mt15  bgWhite radius10 boxshadow20 pb15" >
				<view class="moduletitle  align-center justify-start plr15">
					<text></text>
					<view class="ft16 ml10">
						上传身份证反面(国徽面)
					</view>
				</view>
				<view class="maininfo justify-center align-center">
					<image v-if="form.back_image" :src="form.back_image" class="mt15" mode="widthFix"></image>
				<image style="width: 400rpx;" src="/static/images/sfz2.png" mode="widthFix"  @click="upImg(2)"></image>
					
				</view>
			<view class="ft12 mlr15 mt15" style="color: red;">
				   温馨提示：请您在上传身份证时，确保身份证的正反面照片均为正面朝上、水平放置。照片应清晰可见，不得竖立或倾斜。
			</view>
			<view class="mt10 mb10 mlr15 ptb15 plr15 radius10 ft12" style="background-color: #f1f1f1;color: #ccc;">
				检查照片预览，再次确认照片方向正确，无倾斜
			</view>
			<view class="mt10 mb20 mlr15 ptb15 plr15 radius10 ft12" style="background-color: #f1f1f1;color: #ccc;">
				以免影响审核进度
			</view>
			</view>
		</block>
		<view class="backOrSave boxshadow20 mt15 mb15">
			<view class="back-box" @click="back">
				<view class="info-box">
					<!-- <image src="/static/images/back.png" mode=""></image> -->
					返回
				</view>
			</view>
			<view class="save-box">
				<view class="info-box" @click="save">
					<!-- <image src="/static/images/save.png" mode="w"></image> -->
					保存
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	let app = getApp();
	export default {
		components: {

		},
		data() {
			return {
				act: 0,
				id: "",
				form: {},
				isLogin: uni.getStorageSync('logintoken'),
				muluList: [],
				avatarData: "",
				type:''
			}
		},
		onLoad(opt) {
			this.type= opt.type
			this.$api.userIndex().then(res => {
				console.log(res)
				this.form = res.data

			})

		},
		mounted() {



			// 使用函数生成一个正弦波形


		},

		methods: {
			upImg(type) {
				let vm = this
				uni.chooseImage({
					count: 1,


					success: async function(res) {
						console.log(res)
						// 预览图片
						const result = await vm.$api.uploadImg({
							filePath: res.tempFilePaths[0]
						})
						console.log(result)
						// vm.ruleForm.filePath = vm.$domain.ossapi+result.data
						if(vm.type=='0'){
							vm.form.avatar = result.data.fullurl
						}else if(vm.type=='1'){
							vm.form.zhengshu = result.data.fullurl
							
						}else{
							if(type==1){
								vm.form.front_image=result.data.fullurl
							}else{
								vm.form.back_image=result.data.fullurl
							}
						}
						
						
					}
				});
			},
			back() {
				uni.navigateBack()
			},
			save() {
				this.$api.profile(this.form).then(res => {
					console.log(res)
					if (res.code == 1) {
						this.$utils.msg('修改成功')
						setTimeout(() => {
							uni.navigateBack()
						}, 1000)
					} else {
						this.$utils.msg(res.msg)
					}
				})
			}


		}





	}
</script>
<style scoped lang="scss">
	page {
		color: #343434;
	}

	.header {
		width: 100%;
		height: 110rpx;
		background-color: #fff;

		box-sizing: border-box;
		color: #969696;
		position: fixed;
		top: 88rpx;
		left: 0;
		z-index: 999;
		display: flex;

		view {
			text-align: center;
			font-size: 28rpx;
			height: 100%;
			display: flex;
			align-items: center;
			justify-content: center;
		}

		.on {
			color: #000;
			position: relative;
		}

		.on::after {
			content: "";
			width: 20rpx;
			height: 4rpx;

			background: #0082DB;
			position: absolute;
			bottom: 0;
			left: 0;
			right: 0;
			margin: auto;

		}

		.middle {
			position: relative;
		}

		.middle::after {
			content: "";
			width: 2rpx;
			height: 30rpx;
			background: #E0E0E0;
			position: absolute;
			top: 0;
			bottom: 0;
			margin: auto;
			right: 0;
		}

		.middle::before {
			content: "";
			width: 2rpx;
			height: 30rpx;
			background: #E0E0E0;
			position: absolute;
			top: 0;
			bottom: 0;
			margin: auto;
			left: 0;
		}
	}



	.tag {
		background-color: rgb(255, 219, 109);
		color: #fff;
		font-size: 26rpx;
		padding: 4rpx 8rpx;
		border-radius: 10rpx;
		margin-right: 10rpx;
	}

	.coursedata {
		padding: 20rpx;
		color: #969696;
		font-size: 24rpx;

		image {
			width: 300rpx;
			height: 236rpx;
			border-radius: 15rpx;
			margin-right: 20rpx;
		}

		.title {
			font-size: 33rpx;
			color: #000;
			margin-bottom: 10rpx;
		}

		.price {
			font-weight: bold;
			color: #1FACFF;
			font-size: 42rpx;
		}
	}

	.menudata {
		margin: 20rpx 0;
		// height: 72rpx;
		// border: 1px solid #cad9fe;
		font-size: 28rpx;
		border-radius: 16rpx;
		padding: 30rpx;
		// padding: 0 20rpx;
	}

	.moduletitle {
		height: 116rpx;

		text {

			width: 6rpx;
			height: 18rpx;
			background: #0082DB;
			border-radius: .5rem;
			display: block;
		}
	}

	.maininfo {
		border-top: 2rpx solid #E0E0E0;


	}

	.submit {
		width: 700rpx;
		padding: 20rpx;
		height: 140rpx;
		border-radius: 20rpx;
		position: fixed;
		left: 0;
		right: 0;
		margin: auto;
		bottom: 40rpx;
	}

	.logbtn {
		background: linear-gradient(180deg, #98D5FF 0%, #0082DB 100%);
		border-radius: 20rpx;
		width: 100%;
		height: 100rpx;
		text-align: center;
		line-height: 100rpx;
		color: #fff;
	}

	.slottitle {
		font-size: 34rpx;
		color: #343434;

		image {
			width: 56rpx;
			height: 56rpx;
		}
	}

	.contentbox {
		border: 1px solid #E0E0E0;
		border-radius: 15rpx;
		padding: 10rpx 20rpx;
		font-size: 24rpx;
	}

	.contentTitle {
		width: 147rpx;
		height: 84rpx;
		background-image: url('../../static/images/bg6.png');
		background-size: 100% 100%;
		margin-right: 20rpx;
		text-align: center;
		line-height: 84rpx;
		color: #0082DB;
	}

	.backOrSave {
		width: 100%;
		background-color: #FFFFFF;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0px 12rpx;
		height: 140rpx;
		border-radius: 16rpx;

		.back-box,
		.save-box {
			height: 106rpx;
			width: 300rpx;
			background-color: #e5f2fc;
			border-radius: 16rpx;
			display: flex;
			justify-content: center;
			align-items: center;

			.info-box {
				display: flex;
				justify-content: center;
				align-items: center;
				color: #0484dc;
				font-size: 32rpx;

				image {
					width: 42rpx;
					height: 42rpx;
					margin-right: 24rpx;
				}
			}

		}

		.save-box {
			background-color: #5eb5f1;

			.info-box {
				color: #FFFFFF;
			}
		}
	}

	.plus {
		width: 200rpx;
		height: 200rpx;
		background: #fff;
		border: 1px solid #4080FF;
		border-radius: 15rpx;
	}

	// /deep/.uv-collapse-item__content{
	// 	height: auto!important;
	// }
</style>